//商品详情展示
function showDetail(ordersId) {
    $.ajax({
        url : "orders/delivery",
        async : true,
        type : "GET",
        data : {
            "ordersId" : ordersId
        },
        // 成功后开启模态框
        success : queryDetail,
        error : function(res) {
            alert("收货信息获取失败");
        },
        dataType : "json"
    });
}
function queryDetail(res) {
    if(res.code!=0){
        alert(res.msg);
    }
    var model = res.data;
    if(model===null||model===undefined){
        alert("该订单未填写收货信息");
        return;
    }
    $("#deliveryName").text(model.deliveryName);
    $("#deliveryPhone").text(model.deliveryPhone);
    $("#deliveryCity").text(model.deliveryCity);
    $("#deliveryAddr").text(model.deliveryAddr);
    // 显示模态框
    $('#detailModal').modal('show');
}


//发货展示
function showSend(ordersId) {
    $("#ordersId").val(ordersId);
    $('#sendModal').modal('show');
}

//发货提交
$("#sendButton").click(function () {
    var formdata = new FormData(document.getElementById("sendForm"));
    $.ajax({
        type: "POST",
        url:"orders/send",
        data:formdata,	// 序列化表单值
        processData:false,
        contentType:false,
        error: function(request) {
            alert("未知错误！");
        },
        success: function(res) {
            if(res.code==0) {
                alert("发货成功！");
                window.location.reload();
            }else{
                alert(res.msg);
            }
        }
    });
});

